package com.xjtu.project.controller.admin;

import com.xjtu.project.common.utls.JsonResponse;
import com.xjtu.project.model.vo.SalesTop10ReportVO;
import com.xjtu.project.model.vo.TurnoverReportVO;
import com.xjtu.project.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/api/admin/report")
public class ReportController {
    @Autowired
    private ReportService reportService;
     @GetMapping("/top10")
     public JsonResponse<SalesTop10ReportVO> getSalesTop10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
         return JsonResponse.success(reportService.getSalesTop10(begin, end));
     }
     @GetMapping("turnoverStatistics")
    public JsonResponse<TurnoverReportVO> getTurnover(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
         return JsonResponse.success(reportService.getTurnover(begin, end));
    }
}
